/**
 * 主路由
 */
import { lazy, Suspense } from "react";
import { Spin } from "antd";
import Applayout from "../pages/AppLayout";

const Home = lazy(() => import("../pages/Home"));
const List = lazy(() => import("../pages/Test/List"));
const NotFound = lazy(() => import("../pages/NotFound"));

const lazyLoad = (children) => {
  return <Suspense fallback={<Spin />}>{children}</Suspense>;
};

const router = [
  {
    path: "/",
    element: <Applayout />,
    children: [
      {
        element: lazyLoad(<Home />),
        index: true,
      },
      {
        path: "list",
        element: lazyLoad(<List />),
      },
    ],
  },
  {
    path: "/login",
    element: lazyLoad(<div>Login</div>),
  },
  {
    path: "*",
    element: lazyLoad(<NotFound />),
  },
];

export default router;
